package com.example.boot.service.simple_test.impl;

import com.example.boot.domain.Payment;
import com.example.boot.mapper.simple_test.PaymentMapper;
import com.example.boot.service.simple_test.IOrderService;
import com.example.boot.service.simple_test.IPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderService implements IOrderService {
    @Autowired
    private IPaymentService iPaymentService;
    @Autowired
    private PaymentMapper paymentMapper;

    @Override
    public void funcA(){
        iPaymentService.funcA();
    }

    @Override
    public void funB() {
        System.out.println("wwwww");
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void testTran1() {

        Payment payment = paymentMapper.selectById(1001);
        payment.setSerial("5000");
        paymentMapper.updateById(payment);

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void testTran2() {
        Payment payment = paymentMapper.selectById(1001);
        payment.setSerial("3000");
        paymentMapper.updateById(payment);
        int i = 1 / 0;
    }
}
